package com.xinyue.game.gateway.common;

import com.xinyue.game.message.GameMessageType;
import com.xinyue.game.message.GameServerMessageModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author 王广帅
 * @since 2023/7/25 21:30
 **/
public class GatewayResponseUtil {
    private static Logger logger = LoggerFactory.getLogger(GatewayResponseUtil.class);

    public static GameServerMessageModel<GameGatewayMessageResponseHeader> getResponseMessageModel(GameServerMessageModel<GameGatewayMessageRequestHeader> gatewayMessageWrapper, int errorCode, String errorMsg) {
        GameGatewayMessageRequestHeader requestHeader = gatewayMessageWrapper.getHeader();
        GameGatewayMessageResponseHeader header = new GameGatewayMessageResponseHeader();
        header.setRequestUri(requestHeader.getRequestUri());
        header.setRequestId(requestHeader.getRequestId());
        header.setUserKey("-");
        header.setResponseTime(System.currentTimeMillis());
        header.setMessageType(GameMessageType.RESPONSE.getType());
        header.setErrorCode(errorCode);
        header.setErrorMsg(errorMsg);
        GameServerMessageModel<GameGatewayMessageResponseHeader> messageModel = new GameServerMessageModel<>();
        messageModel.setHeader(header);
        return messageModel;
    }


}
